// Problem 225: Tribonacci non-divisors
// The sequence 1, 1, 1, 3, 5, 9, 17, 31, 57, 105, 193, 355, 653, 1201 …
// is defined by T1 = T2 = T3 = 1 and Tn = Tn-1 + Tn-2 + Tn-3.
// It can be shown that 27 does not divide any terms of this sequence. In fact, 27 is the first odd number with this property.
// Find the 124th odd number that does not divide any terms of the above sequence.

package main

import "fmt"

func p225() {
	var s1, s2, s3, s4 int
	odd, ans := 25, 0
	for {
		odd += 2
		s1, s2, s3 = 1, 1, 3
		divided := false
		for (s3 != 1) || (s2 != 1) || (s1 != 1) {
			s4 = (s1 + s2 + s3) % odd
			if s4 == 0 {
				divided = true
				break
			}
			s1, s2, s3 = s2, s3, s4
		}
		if divided == false {
			ans++
		}
		if ans == 124 {
			fmt.Println("Problem 225:", odd)
			return
		}
	}
}
